class Solution {
public:
    vector<int> res;
    void traversal(TreeNode* root){
   //   if(root == NULL) return;
      if(root->left) traversal(root->left);
      res.push_back(root->val);
      if(root->right) traversal(root->right);
    }
    bool isValidBST(TreeNode* root) {
      traversal(root);
      int len = res.size();
      for(int i = 0;i < len - 1;i++){
        if(res[i] >= res[i + 1]){
          return false;
        }
      }
      return true;
    }
};
